#pragma once

#include "topcvt_exception.hpp"
#include "topcvt_unpack.hpp"
#include "topcvt_pack.hpp"

namespace topcvt
{
	/*
	*	<?xml version="1.0" encoding="GBK"?>
	*	<root>
	*		<policy type="tlv" tagLen="4" lenLen="2" >
	*		</policy>
	*	</root>
	*/

	class TlvUnpack : public UnpackImp
	{
	public:
		TlvUnpack(ByteBuffer& message)
			: UnpackImp(message)
		{}
		void checkElementCfgValid(AttributeableCfg& t) override;
		PolicyContext& unpackPolicy(PolicyContext& ctx, PolicyCfg& policyCfg) override;
		string unpackField(pugi::xml_node& node, FieldCfg& f, PolicyContext& ctx) override;
	};

	class  TlvPack : public  PackImp
	{
	public:
		void checkElementCfgValid(AttributeableCfg& t) override;
		string packPolicy(PolicyContext& policyContext, PolicyCfg& policyCfg) override;
		void packField(pugi::xml_node& node, FieldCfg& f, PolicyContext& ctx) override;
	};
};